Skip to content

str: add ASCII fast path to word_to_titlecase#159271

Open
Rachit2323 wants to merge 2 commits into
rust-lang:mainfrom
Rachit2323:fix-titlecase-ascii-fastpath
Open

str: add ASCII fast path to word_to_titlecase#159271
Rachit2323 wants to merge 2 commits into
rust-lang:mainfrom
Rachit2323:fix-titlecase-ascii-fastpath

Conversation

@Rachit2323

@Rachit2323 Rachit2323 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

The word_to_titlecase function had a FIXME comment since a long time asking to add a fast path for ASCII text.

Before this change, even simple English text like "hello world" was going through slow Unicode lookup tables. That was unnecessary.

This fixes it by using the same trick that to_lowercase already uses — plain English letters are now handled much faster, and only Greek/Chinese/etc still use the Unicode tables.

No behavior changes, just faster for normal English text.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 14, 2026
@rustbot

rustbot commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @clarfonthey (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from 6 candidates

Comment thread library/alloctests/tests/str.rs
@rust-bors

This comment has been minimized.

@Rachit2323
Rachit2323 force-pushed the fix-titlecase-ascii-fastpath branch from 621e917 to ac53b43 Compare July 15, 2026 10:34
@rustbot

rustbot commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@clarfonthey

Copy link
Copy Markdown
Contributor

Finally got to reviewing this, new tests look good, and I think this should be fine. Thank you!

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

📌 Commit ac53b43 has been approved by clarfonthey

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 24, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 24, 2026
…tpath, r=clarfonthey

str: add ASCII fast path to word_to_titlecase

The word_to_titlecase function had a FIXME comment since a long time asking to add a fast path for ASCII text.

Before this change, even simple English text like "hello world" was going through slow Unicode lookup tables. That was unnecessary.

This fixes it by using the same trick that to_lowercase already uses — plain English letters are now handled much faster, and only Greek/Chinese/etc still use the Unicode tables.

No behavior changes, just faster for normal English text.
rust-bors Bot pushed a commit that referenced this pull request Jul 24, 2026
Rollup of 12 pull requests

Successful merges:

 - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap)
 - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata)
 - #158362 (trait solver: account for universes from replace_bound_vars)
 - #159173 (Add allowed list check on EII implementations attributes)
 - #159718 (Make `DocLinkResMap` an `FxIndexMap`)
 - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature)
 - #155795 (constify `vec![1, 2, 3]` macro)
 - #157776 (ci: Enable autodiff tests on x86_64 linux)
 - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools)
 - #159271 (str: add ASCII fast path to word_to_titlecase)
 - #159666 (fix(ld64.lld): route version mismatch warnings to linker_info on macOS)
 - #159667 (Make some parser structured suggestions verbose and tweak their wording)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 24, 2026
…tpath, r=clarfonthey

str: add ASCII fast path to word_to_titlecase

The word_to_titlecase function had a FIXME comment since a long time asking to add a fast path for ASCII text.

Before this change, even simple English text like "hello world" was going through slow Unicode lookup tables. That was unnecessary.

This fixes it by using the same trick that to_lowercase already uses — plain English letters are now handled much faster, and only Greek/Chinese/etc still use the Unicode tables.

No behavior changes, just faster for normal English text.
rust-bors Bot pushed a commit that referenced this pull request Jul 24, 2026
Rollup of 14 pull requests

Successful merges:

 - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap)
 - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata)
 - #158362 (trait solver: account for universes from replace_bound_vars)
 - #158372 (rustfmt: Discover modules via `cfg_select!`)
 - #159173 (Add allowed list check on EII implementations attributes)
 - #159718 (Make `DocLinkResMap` an `FxIndexMap`)
 - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature)
 - #159731 (std: Implement futex on wasip3 targets, update target spec)
 - #159755 (Improve consistency of attribute error messages)
 - #155795 (constify `vec![1, 2, 3]` macro)
 - #157776 (ci: Enable autodiff tests on x86_64 linux)
 - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools)
 - #159271 (str: add ASCII fast path to word_to_titlecase)
 - #159667 (Make some parser structured suggestions verbose and tweak their wording)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants